// @charset "utf-8";
/**
 * 个股涨跌画图
 */
define(function(require, exports, module) {

	var rzrqChart = {
		$chartDom : $('#view_div_rzrqchart'),
		render : function (rzrqParam) {
			var self = this;
			var blackColor = '#bbb';
			if (commonMethod.thsSkin == 'white') {
				blackColor = '#444';
			}
			var rzrqChartOptions = {
				colors: ['#047cf4'],
				credits: {
					enabled: false
				},
				chart: {
					backgroundColor: "rgba(0,0,0,0)",
					style: {
						fontFamily: "arial"
					},
					marginTop: 40
				},
				title: {
					text: ''
				},
				xAxis: {
					lineWidth: 1,
					tickLength: 4,
					tickColor: '#808080',
					title: {
						text: ''
					},
					categories: rzrqParam.categories,
					gridLineWidth: 0,
					labels: {
						align: 'center',
						rotation: 'auto',
						style: {
							color: '#afafaf'
						}
					},
					lineColor: '#808080'
				},
				yAxis: [{
					lineWidth: 1,
					tickColor: '#808080',
					tickPosition: 'outside',
					gridLineWidth: 0,
					tickLength: 4,
					tickWidth: 1,
					tickInterval: 250,
					// tickPixelInterval: 40,
					// showLastLabel:true,
					maxPadding: 0.04,
					title: {
						text: ''
					},
					lineColor: '#808080',
					labels: {
						format: '{value}',
						style: {
							color: '#afafaf'
						},
						x: -6
					},
					min: rzrqParam.yminData

				}, {
					gridLineWidth: 0,
					lineWidth: 1,
					tickPosition: 'outside',
					tickColor: '#808080',
					tickLength: 4,
					tickWidth: 1,
					// tickInterval: 100,
					// tickPixelInterval: 40,
					title: {
						text: '',
						style: {
							color: '#414141'
						}
					},
					opposite: true,
					lineColor: '#808080',
					labels: {
						format: '{value}',
						style: {
							color: '#afafaf'
						},
						x: 6
					}

				}],
				series: [{
					name: '两融余额(亿元)',
					type: 'column',
					yAxis: 0,
					marker: {
						enabled: false,
						states: {
							hover: {
								color: 'pink'
							}
						}
					},
					data: rzrqParam.rzrqData
				}, {
					name: '上证',
					type: 'line', //spline
					yAxis: 1,
					marker: {
						enabled: false,
						states: {
							hover: {
								fillColor: '#e8424f',
								lineWidth: 1,
								lineColor: 'rgba(255, 255, 255, 0.8)',
								radius: 4,
								lineWidthPlus: 10
							}
						}
					},
					data: rzrqParam.shData
				}],
				legend: {
					align: 'right',
					verticalAlign: 'top',
					symbolHeight: 10,
					floating: false,
					itemStyle: {
						color: blackColor,
						fontFamily: 'Simsun',
						fontWeight: 'normal'
					},
					itemHiddenStyle: {},
					itemHoverStyle: {
						color: '#bbb'
					},
					x: 8,
					y: -10
				},
				plotOptions: {
					column: {
						borderColor: '#047cf4',
						borderWidth: 0,
						pointWidth: 12,
						states: {
							hover: {
								brightness: 0.2
							}
						},
						events: {
							// mouseOver : function () {
							// 	chartTaidTimer = setTimeout(function () {
							// 		var time = ((+new Date()) / 1000).toFixed(0);
							// 		TA.log({"id":time,"fid":"zx_565d20c4_290"});
							// 	}, 1200);
							// },
							// mouseOut : function () {
							// 	clearTimeout(chartTaidTimer);
							// }
						}

					},
					line: {
						color: '#e8424f',
						states: {
							hover: {
								lineWidthPlus: 0
							}
						},
						events: {
							// mouseOver : function () {
							// 	chartTaidTimer = setTimeout(function () {
							// 		var time = ((+new Date()) / 1000).toFixed(0);
							// 		TA.log({"id":time,"fid":"zx_565d20c4_290"});
							// 	}, 1200);
							// },
							// mouseOut : function () {
							// 	clearTimeout(chartTaidTimer);
							// }
						}
						// pointStart:100
					}

				},
				tooltip: {
					shadow: false,
					shared: true,
					backgroundColor: 'rgba(255, 255, 255, 0.9)',
					formatter: function() {
						var i = $.inArray(this.x, rzrqParam.categories);
						var contr = rzrqParam.contrastData[i] > 0 ? "+" + rzrqParam.contrastData[i] : rzrqParam.contrastData[i];
						var str = '两融余额:' + this.points[0].y + '亿<br/>' + '相比上一交易日:' + contr + '亿<br/>' + this.points[1].series.name + ':' + this.points[1].y.toFixed(0);
						return str;
					},
					valueDecimals: 0,
					style: {
						fontFamily: "arial"
					}
				}
			};
			self.$chartDom.highcharts(rzrqChartOptions);
			self.rzrqHighcharts = self.$chartDom.highcharts();
		},
		rzrqHighcharts: null,
		reflowChart: function () {
			var self = this;
			if (self.rzrqHighcharts != null) {
				self.rzrqHighcharts.reflow();
			}
		}
	};

	module.exports = rzrqChart;
});